package com.cloud.bssp.gateway.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.ArrayList;
import java.util.List;

/**
 * @description： 接口文档controller
 * @author：weirx
 * @date：2021/3/30 14:15
 * @version：3.0
 */
@RestController
@RequestMapping("/swagger")
public class SwaggerController {

    @Autowired
    private SwaggerResourcesProvider swaggerResources;

    @GetMapping("/getServiceName")
    public List<String> swaggerResources() {
        List<SwaggerResource> swaggerResources = this.swaggerResources.get();
        List<String> list = new ArrayList<>(swaggerResources.size());
        swaggerResources.forEach(s->list.add(s.getName()));
        return list;
    }

}
